// routes.js
const express = require('express');
// const usersRouter = require('@/router/user');
const userController = require('@/controllers/userController');
const articleController = require('@/controllers/articleController');
const adminController = require('@/controllers/adminController');


// 创建子应用
const apiRouter = express.Router();
// 注册路由到子应用

apiRouter.use('/user', userController);
apiRouter.use('/article', articleController);
apiRouter.use('/article', adminController);


module.exports = function(app) {
    app.use('/user', userController);
    app.use('/article', articleController);
    app.use('/admin', adminController);

     // 将子应用挂载到主应用上，使用 '/api' 作为前缀，这样使用/user 还是/api/user都能正常访问
    app.use('/api', apiRouter);
};